/********************************************************************************
TITLE:                      	Using Virtual Functions
FILENAME:                   	audiocassette.cpp
PREPARED FOR:               	CS215 Section CS13-02
PROGRAMMER(S):              	Eric (Fox) Crowell, Timothy Drye
DEVELOPMENT DATE:           	< 12/15/13 >
COMPILER USED:      			Microsoft Visual Studio Professional 2013
- Version 12.0.21005.1 REL
TARGET PLATFORM:         	    Windows 8 x64
================================================================================
REVISION HISTORY

DATE         PROGRAMMER          DESCRIPTION OF CHANGES MADE
------------------------------------------------------------------------------
<12/18/13       Fox                 Class Created.                           >
*******************************************************************************/

#include "audiocassette.h"

// For the default constructor, call the parent's and set. [Fox]
AudioCassette::AudioCassette() :Media() {
	cout << "      --- Number of Selections: ";
	cin >> NumberOfSelections; // Int
	if (NumberOfSelections < 1){ NumberOfSelections = 1; }
	cout << "      [i] Your \"Audio Cassette\" media item has been created.\n";
	cout << "      --------------------------------------------------\n\n";
}

// Overloaded constructor. [Fox]
AudioCassette::AudioCassette(const string  & InTitle, const string & InArtist, const string & InWherePurchased,
	float InCost, Time  & InRunningTime, int InNumberOfSelections)
	:Media(InTitle, InArtist, InWherePurchased, InCost, InRunningTime) {
	NumberOfSelections = InNumberOfSelections;
}

// Returns the boolean data member IsCassetteAtBeginning. [Fox]
bool AudioCassette::IsCassetteAtBeginning() {
	return(CassetteAtBeginning);
}

// Returns the boolean data member CassetteAtEnd. [Fox]
bool AudioCassette::IsCassetteAtEnd(){
	return(CassetteAtEnd);
}

// Returns the boolean data member NumberOfSelections. [Fox]
int AudioCassette::GetNumberOfSelections(){
	return(NumberOfSelections);
}

// Returns the boolean data member CurrentSelection. [Fox]
int AudioCassette::GetCurrentSelection(){
	return(CurrentSelection);
}

// Play the media (Progresses the end of the media). [Fox]
void AudioCassette::Play(){
	if (IsCassetteAtEnd() || CurrentSelection > NumberOfSelections){
		cout << "\n      [!] This media has reached the end of its playlist. Please rewind the media before playing.\n\n";
		CassetteAtBeginning = false;
		CassetteAtEnd = true;
	}
	else{
		cout << "\n      [i] Media has just played selection #" << CurrentSelection << ".\n";
		CurrentSelection++;
		if (CurrentSelection <= NumberOfSelections){
			cout << "      [i] Next track is #" << CurrentSelection << ".\n\n";
		}
		else {
			cout << "      [i] That was the last track in the playlist.\n\n";
		}
		CassetteAtBeginning = false;
		CassetteAtEnd = false;
	}
}

// Fast forward to the end of the media. [Fox]
void AudioCassette::FastForward(){
	if (IsCassetteAtEnd()){
		cout << "\n      [!] This media is already at the end.\n\n";
	}
	else {
		cout << "\n      [i] Media has been fast forwarded to the end.\n\n";
		CassetteAtBeginning = false;
		CassetteAtEnd = true;
	}
}

// Rewind to the begining of the media. [Fox]
void AudioCassette::Rewind(){
	if (IsCassetteAtBeginning()){
		cout << "\n      [!] This media is already at the beginning.\n\n";
	}
	else {
		cout << "\n      [i] Media has been rewound to the beginning.\n\n";
		CassetteAtBeginning = true;
		CassetteAtEnd = false;
	}
}

// Prints out the information about the media. [Fox]
void AudioCassette::PrintMedia(ostream & Out){
	Media::PrintMedia(Out); // Call the parent's PrintMedia to output its data members.
	Out << "      --- Number of Selections: " << NumberOfSelections << "\n";
	Out << "      --- Media Type: Audio Cassette\n";
	Out << "      --------------------------------------------------\n\n";
}